<?php
include_once './person.php';
include_once './admin.php';
include_once './building.php';
include_once './data_access.php';
include_once './room.php';

$data=new database_access();
$data->connect();
$admin=new admin();
$building=new building();
$room=  new room();

$id=$_POST['id'];
$capacity=$_POST['capacity'];
$periority=$_POST['periority'];
$resdient_kind=$_POST['resdient_kind'];
$num_room=$_POST['rooms'];
$room_capacity=$_POST['roomcapacity'];

$building->set_id($id);
$building->set_capacity($capacity);
$building->set_periority($periority);
$building->set_resdient_kind($resdient_kind);
$building->set_number_rooms($num_room);
$room->set_capacity($room_capacity);

$exist_build=$admin->check_exist_building($building);
//$check_periority=$admin->check_building_periority($building);




if($_POST['submit']&&$capacity&&$id&&$periority&&$resdient_kind&&$id){
if($exist_build==0){//&&$check_periority==0
   
  
$admin->addbuilding($building);
$admin->add_rooms($room, $building);
echo 'building has been added';
}
 

 else {
    echo "this build is exst"."<br /> "; 
     echo $kind;
 }}
else 
    {
    
    header('location: add_building.php');
  
}
 
?>




 